﻿@section Scripts {
    @Scripts.Render("~/bundles/app")
}
<div class="row">
    <div class="col-sm-4">
        <h3>Response From Server</h3>
        <div class="form-group">
            <label>Return Code</label>
            <input class="form-control" type="text" readonly data-bind="value: code" />
        </div>
        <div class="form-group">
            <label>Message</label>
            <textarea class="form-control" readonly data-bind="value: message"></textarea>
        </div>
    </div>
    <div class="col-sm-4">
        <form data-bind="submit: register">
            <h3>Register</h3>
            <div class="form-group">
                <label>User Name</label>
                <input class="form-control" type="text" data-bind="value: registerUserName" />
            </div>
            <div class="form-group">
                <label>Email</label>
                <input class="form-control" type="text" data-bind="value: registerEmail" />
            </div>
            <div class="form-group">
                <label>Password</label>
                <input class="form-control" type="password" data-bind="value: registerPassword" />
            </div>
            <div class="form-group">
                <button type="submit" class="btn btn-default">Register</button>
            </div>
        </form>
    </div>
    <div class="col-sm-4">
        <h3>Log In</h3>
        <form data-bind="submit: login">
            <div class="form-group">
                <label>User Name</label>
                <input class="form-control" type="text" data-bind="value: loginUserName" />
            </div>
            <div class="form-group">
                <label>Password</label>
                <input class="form-control" type="password" data-bind="value: loginPassword" />
            </div>
            <div class="form-group">
                <button type="submit" class="btn btn-default">Log In</button>
                <button data-bind="click: logout" class="btn btn-default">Log Out</button>
            </div>
        </form>
    </div>
</div>

<div id="summary" class="section panel panel-primary"
     data-bind="if: app.displayUserSummary">
    <div class="panel-heading">User List</div>
    <div class="panel-body">
        <table class="table table-striped table-condensed">
            <thead>
                <tr><th>ID</th><th>Name</th><th>Email</th><th>Password</th></tr>
            </thead>
            <tbody data-bind="foreach: app.users">
                <tr>
                    <td data-bind="text: UserId"></td>
                    <td data-bind="text: UserName"></td>
                    <td data-bind="text: Email"></td>
                    <td data-bind="text: Password"></td>                    
                </tr>
            </tbody>
        </table>
    </div>
</div>
<div>
  <pre>
   Get All Restaurant
   URL: http://127.0.0.1:8080/api/Restaurant/GetAll
   Method: Get

   Set Rating
   URL: http://127.0.0.1:8080/api/Restaurant/SetRate
   Method: Post
   Data: 
       RestId:1
       Rating:5
  </pre>
  <pre>
   Get All Comments
   URL: http://127.0.0.1:8080/api/comment/GetAll
   Method: Get

   Get Comments By Restaurant
   URL: http://127.0.0.1:8080/api/comment/GetListByRestaurant?restid=1
   Method: Get

   Get Comments By User
   URL: http://127.0.0.1:8080/api/comment/GetListByUser?id=1
   Method: Get

   Submit Comment
   URL: http://127.0.0.1:8080/api/comment/create
   Method: Post
   Data: 
       RestId: 1
       UserName: Johnny
       Content: Very good
  </pre>
  <pre>
   Get All User
   URL: http://127.0.0.1:8080/api/User/GetAll
   Method: Get
  </pre>
  <pre>
   Register: 
    URL: http://127.0.0.1:8080/api/User/Register
    Method: Post
    Data: 
        UserId:0
        UserName:johnny
        Email:jojo@gmail.com
        Password:aaa
  </pre>
  <pre>
   Login: 
    URL: http://127.0.0.1:8080/api/User/Login
    Method: Post
    Data: 
       UserName:johnny
       Password:aaa
  </pre>
  <pre>
   Logout: 
    URL: http://127.0.0.1:8080/api/User/Logout
    Method: Post
    Data: 
       UserName:johnny
  </pre>

  <pre>
   Return Json: 
      {"RetCode":0,"Message":"Registration succeed!"}
      {"RetCode":1,"Message":"User Name, Email or Password can't be empty!"}

  </pre>
</div>